﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CSharp.Libs.Koc;

namespace CSharp.Libs.WPF.UserControls
{
    /// <summary>
    /// Interaction logic for KocSeedViewerControl.xaml
    /// </summary>
    /// <history>created  06.02.2013</history>
    public partial class KocSeedViewerControl : UserControl
    {
        #region declarations
        private KocSeedViewerControlViewModel _KSVCVM = null;
        private Kernel _KRNL = null;
        #endregion



        #region constructor / finalizer
        public KocSeedViewerControl()
        {
            InitializeComponent();
        }
        #endregion



        #region event handling
        private void mnuCopyText_Click(object sender, RoutedEventArgs e)
        {
            if (lvSeeds.SelectedItems.Count == 1)
            {
                KocSeedViewerItem ksvi = lvSeeds.SelectedItem as KocSeedViewerItem;
                if (ksvi != null)
                {
                    Clipboard.SetText(ksvi.SeedText);
                    MessageBox.Show("SeedText of '" + ksvi.Key + "' copied to Clipboard");
                }
            }
        }
        #endregion



        #region private functions
        private void _InitializeVM(
            Kernel KRNL)
        {
            _KRNL = KRNL;
            _KSVCVM = new KocSeedViewerControlViewModel(this.Dispatcher, _KRNL);
            DataContext = _KSVCVM;
        }
        #endregion



        #region interface
        #region properties
        /// <summary>
        /// 
        /// </summary>
        /// <history>created  06.02.2013</history>
        public KocSeedViewerControlViewModel KSVCVM { get { return _KSVCVM; } }

        /// <summary>
        /// 
        /// </summary>
        /// <history>created  06.02.2013</history>
        public KocSeedViewerControlViewModel ViewModel { get { return _KSVCVM; } }
        #endregion

        #region methods
        /// <summary>
        /// 
        /// </summary>
        /// <param name="KRNL"></param>
        /// <history>created  06.02.2013</history>
        public void InitializeVM(
            Kernel KRNL)
        {
            _InitializeVM(KRNL);
        }

        public void Unload()
        {
            _KSVCVM.Dispose();
        }
        #endregion
        #endregion
    }
}
